/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.service;

import com.dao.GradeDao;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

/**
 *
 * @author DELL
 */
public class GradeQuery {
    
    
    public List getGrade(Integer id,int page2){
        
                   HttpServletRequest request;
        request =ServletActionContext.getRequest();
                HttpSession session=request.getSession();
        
        
        Integer  stid=id;
         int page=page2;
    if(page==0){
    page=1;
    }
    
    
                Logger.getLogger(this.getClass().getName()).log(Level.INFO, "aaaaaiiiiiiiiiiii11122222222222222222222222222211111");
           GradeDao gradeDao=new GradeDao();  
           
           Integer sum=new Integer(gradeDao.countSum(stid));
           int pp=0;
           if(sum%8==0){
                     pp=sum/8;
           }
           else {
                        pp=sum/8+1;
           }
           Integer pages=new Integer(pp);
           session.setAttribute("sum", sum);
           session.setAttribute("pages", pages);
           session.setAttribute("curPage", page);
           
           
           List gradeList=gradeDao.getGrade2(stid,page);
           return  gradeList;
    }
    
    
    
    
    
    
}
